<template>
	<view>
		<TopNavCustom :title="title"></TopNavCustom>
		<view class="content">
			<text class="time">{{time}}</text>
			<view class="add-zone">
				<view class="add-form">
					<u-cell-group :border="false">
						<u-cell size="normal" title="问题类别" :value="listData.faultName">
						</u-cell>
						<u-cell size="normal" v-if="listData.issuesType == 2 || listData.issuesType == 11">
							<div slot='value'>{{getValue(listData.issueTags)}}</div>
						</u-cell>
						<u-cell size="normal" title="问题部位" :value="listData.issueLocation">
						</u-cell>
						<u-cell size="normal" title="问题处理人" :value="listData.handlerUserId">
						</u-cell>
						<u-cell size="normal" title="发现时间" :value="listData.discoveryTime"></u-cell>
						<u-cell size="normal" title="预计处理时间" :value="listData.estimatedProcessingTime">
						</u-cell>
						<u-cell size="normal" title="问题描述" :border="false"></u-cell>
						<view class="pixs">
							<textarea :value="listData.issuesDesc" placeholder="请描述问题，最多输入200个字" disabled />
						</view>
						<u-cell size="normal" title="现场情况" :border="false"></u-cell>
						<view class="pixs">
							<view class="pixs">
								<view v-for="(img,i) in listData.pixs">
									<image :src="getSrc(img)" class="pix"></image>
								</view>
							</view>
						</view>
					</u-cell-group>
				</view>
			</view>
		</view>
		<view class="btns" v-if="listData.issuesStatus === 3">
			<button type="default" class="next" @click="gotoDelete(()=>showModal = true)">删除</button>
		</view>
		<view class="btns" v-if="listData.issuesStatus === 4">
			<button type="default" class="next" @click="goto()">重新上传</button>
		</view>
		<u-modal @cancel="cancelModal" :show="showModal" :title="modalTitle" :content='content' @confirm="confirm"
			:showCancelButton='true'>
		</u-modal>
	</view>
</template>

<script>
	import $C from '@/common/config.js'
	import _question from "@/common/question.js"
	
	export default {
		data() {
			return {
				modalTitle: '删除记录',
				content: '是否确认删除记录',
				showModal: false,
				opTitle: '',
				failStatus: '',
				pickerDateTitle: '',
				dateTime: Number(new Date()),
				time: uni.$u.timeFormat(false, 'yyyy-mm-dd'),
				listData: {},
				fileIds: [],
				flag: 0,
				formList: [],
				fileList: [],
				columns: [],
				showEmpty: true,
				title: "",
				show: false,
				temp: {}
			};
		},
		onLoad(params) {
			this._para = params.item
			let temp = JSON.parse(decodeURIComponent(params.item))
			console.log(temp)
			this.title = temp.partNames[2]
			this.listData = temp
			this.listData.pixs = temp.issueImages == null ? [] : temp.issueImages.split(',')
			// this.getProgressDetails(temp.progressId)
			console.log(temp)
		},
		methods: {
			getValue(value) {
				if (typeof value == undefined || value == null) {
					return ''
				} else {
					return value
				}
			},
			cancelModal() {
				this.showModal = false
			},
			output() {
				this.modalTitle = '导出记录'
				this.content = '是否确认导出记录'
				this.showModal = true
			},
			getSrc(id) {
				if ((typeof id) != undefined && id != '') {
					let _src = $C.baseUrl + '/file/download?fileId=' + id
					return _src
				}
			},
			async confirm() {
				const result = await _question.deleteQuestionRecord(this.listData.qualityId)
				if (result) {
					uni.$showMsg('删除成功！')
					this.cancelModal()
					uni.$u.sleep(500).then(() => {
						uni.navigateBack({
							delta: 1
						})
					})
				} 
			},
			deleteRecord() {
				this.modalTitle = '删除记录'
				this.content = '是否确认删除记录'
				this.showModal = true
			},
			goto() {
				uni.navigateTo({
					url: '/pages/idata/safe/upload_safe/upload_safe?item=' + this._para
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding: 20rpx 30rpx 58rpx 30rpx;
	}

	.add-zone {
		padding: 20rpx;
		border: 1rpx solid #efefef;
		border-radius: 20rpx;
		background-color: #FFFFFF;
	}

	.add-form {
		display: flex;
		flex-direction: column;

		.pixs {
			padding: 20rpx;
			display: flex;
			flex-direction: row;
			flex-wrap: wrap;
			justify-content: space-around;

			.pix {
				width: 140rpx;
				height: 140rpx;
			}
		}
	}

	.btns {
		margin-top: 88rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-around;
		margin-bottom: 95rpx;

		.next {
			width: 560rpx;
			color: #FFFFFF;
			background: linear-gradient(90deg, #E62129 0%, #BA000A 100%);
			box-shadow: 0rpx 5rpx 15rpx 0rpx rgba(0, 0, 0, 0.05);
			border-radius: 44rpx;
		}

		.edit {
			width: 300rpx;
			color: #FFFFFF;
			background: linear-gradient(90deg, #E62129 0%, #BA000A 100%);
			box-shadow: 0rpx 5rpx 15rpx 0rpx rgba(0, 0, 0, 0.05);
			border-radius: 44rpx;
		}

		.delete {
			width: 300rpx;
			background: #FFFFFF;
			border: 2rpx solid #E62029;
			border-radius: 44rpx;
			color: #E62029;
			// width: 560px
		}
	}
</style>
